﻿#include <iostream>
#include <unordered_map>
#include <sstream>
#include <string>
#include <cmath>

using namespace std;

bool isPrime(int n) {
    if (n <= 1)
        return false;

    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0)
            return false;
    }

    return true;
}

int wordsToNumber(const string& word1, const string& word2, const string& word3) {
    unordered_map<string, int> wordToDigit = {
        {"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3},
        {"four", 4}, {"five", 5}, {"six", 6}, {"seven", 7},
        {"eight", 8}, {"nine", 9}
    };

    int number = 0;
    if (wordToDigit.count(word1) && wordToDigit.count(word2) && wordToDigit.count(word3)) {
        number = wordToDigit[word1] * 100 + wordToDigit[word2] * 10 + wordToDigit[word3];
    }
    return number;
}

int main() {
    string input;
    getline(cin, input);

    istringstream iss(input);
    string word1, word2, word3;
    if (!(iss >> word1) || !(iss >> word2) || !(iss >> word3) || (iss >> word3)) {
        cout << "Wrong input\n";
        return 0;
    }

    int num = wordsToNumber(word1, word2, word3);

    if (num < 100 || num > 999) {
        cout << "Wrong input\n";
        return 0;
    }

    int nearestPrime = num;
    while (!isPrime(nearestPrime)) {
        nearestPrime++;
    }

    cout << nearestPrime << "\n";

    return 0;
}